/**
 * SPDX-FileCopyrightText: 2023-2025 Sangfor Technologies Inc.
 * SPDX-License-Identifier: Mulan PSL v2
 */
<template>
    <div class="task-list">
        <div class="task-list__head">
            <div class="list-head__title">
                <img src="./img/task_list.png" alt="">
                <lang>
                    任务查看
                </lang>
            </div>
            <div class="list-head__tabs">
                <lang :class="['list-tabs__item',{'list-tabs__item--active': active === TABS_MAP['running_task'] }]"
                      @click.native="handleActive(TABS_MAP['running_task'])">
                    进行任务
                </lang>
                <lang :class="['list-tabs__item',{'list-tabs__item--active': active === TABS_MAP['history_task'] }]"
                      @click.native="handleActive(TABS_MAP['history_task'])">
                    历史任务
                </lang>
            </div>
        </div>
        <div class="task-list__table">
            <page-title :title-name=" _('任务列表') " style="margin-bottom: 20px;margin-left: 0;">
                <i class="iconfont iconsip-refresh refresh" style="cursor: pointer"  @click="loadData"></i>
            </page-title>
            <template v-if="active === TABS_MAP['running_task']">
                <running-task ref="tableRef"/>
            </template>
            <template v-else>
                <history-task ref="tableRef"/>
            </template>
        </div>
    </div>
</template>

<script>
import pageTitle from '../../common/page_title/page_title.vue';
import RunningTask from "./tables/running_task.vue";
import HistoryTask from "./tables/history_task.vue";

import {TABS_MAP} from "./const";

export default {
    name: "TaskList",
    components: {
        pageTitle, RunningTask, HistoryTask
    },
    data() {
        return {
            active: TABS_MAP['running_task'],
            isEmpty: false,
        }
    },
    computed: {
        TABS_MAP() {
            return TABS_MAP;
        }
    },
    methods: {
        loadData() {
            this.$refs.tableRef?.getList();
        },
        handleActive(active) {
            this.active = active;
        },
        toCreateTask() {
            this.$router.push({
                name: 'task_post'
            })
        },
    }
}
</script>

<style scoped lang="less">
.task-list {
    height: 100%;
    
    .task-list__head {
        height: 118px;
        background-color: #fff;
        padding: 21px 24px;
        
        .list-head__title {
            display: flex;
            align-items: center;
            height: 32px;
            line-height: 32px;
            
            & > span {
                margin-left: 16px;
                font-size: 18px;
                font-weight: 500;
                color: #3D3D3D;
            }
        }
        
        .list-head__tabs {
            margin-top: 17px;
            height: 48px;
            
            .list-tabs__item {
                display: inline-block;
                height: 48px;
                line-height: 48px;
                font-size: 14px;
                font-weight: 500;
                text-align: center;
                width: 88px;
                cursor: pointer;
            }
            
            .list-tabs__item--active {
                color: #0052D9;
                border-bottom: 2px solid #0052D9;
            }
            
            .list-tabs__item + .list-tabs__item {
                margin-left: 20px;
            }
        }
    }
    
    .task-list__table {
        height: calc(100% - 170px);
        margin: 20px 24px 32px 24px;
        background: #fff;
        padding: 20px;
        
        .page-title {
            border-bottom: none;
            height: 21px;
        }
        
        /deep/ .el-empty {
            height: calc(100% - 48px);
            
            .el-empty__image {
                .icon-comp-empty-status {
                    font-size: 80px;
                    color: #E0E0E0;
                }
            }
            
            .el-empty__description {
                font-size: 14px;
                line-height: 17px;
                color: #999999;
            }
        }
    }
}
</style>
